package com.atwulidun.visitor14;

public class VisitorDemo {
    public static void main(String[] args) {
        // 创建一个账本
        AccountBook accountBook = new AccountBook();
        // 添加两个收入账单
        accountBook.addBill(new IncomeBill(10000, "卖商品"));
        accountBook.addBill(new IncomeBill(12000, "卖广告位"));
        // 添加两个支出账单
        accountBook.addBill(new ConsumptionBill(1000, "工资"));
        accountBook.addBill(new ConsumptionBill(2000, "材料费"));

        // 创建两个访问者
        AccountBookViewer boss = new Boss();
        AccountBookViewer cpa = new CPA();

        // 让两个访问者分别对账单列表进行访问
        System.out.println("老板对账单列表进行访问：");
        accountBook.visitBills(boss);
        ((Boss) boss).showTotalIncome();
        ((Boss) boss).showTotalConsumption();
        System.out.println("会计对账单列表进行访问：");
        accountBook.visitBills(cpa);

    }
}
